#include <bits/stdc++.h>
#define int long long
using namespace std;
int t, n, ans;
priority_queue<int> q;
void solve() {
  cin >> n;
  for (int i = 1, x; i <= 2 * n; i++) {
    cin >> x;
    q.push(x);
    if (i & 1)
      ans += q.top(), q.pop();
  }
  cout << ans << "\n";
  ans = 0;
  while (!q.empty())
    q.pop();
}
signed main() {
  cin >> t;
  while (t--)
    solve();
  return 0;
}